#
# Copyright (C) 2017 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk

PKG_NAME:=intel_211
PKG_VERSION:=5.15.7
PKG_RELEASE:=1

PKG_MAINTAINER:=Jone Nine<joynine@google.com>
PKG_LICENSE:=GPL-2.0

include $(INCLUDE_DIR)/package.mk

define KernelPackage/intel_211
  SECTION:=sys
  CATEGORY:=Kernel modules
  SUBMENU:=Network Devices
  TITLE:=(LEDE) Intel I211 2.5Gbe Test Drivers
  FILES:=$(PKG_BUILD_DIR)/igb2.ko
  AUTOLOAD:=$(call AutoLoad,26,igb2,1)
  KCONFIG:=
endef

define KernelPackage/intel_211/description
  Intel I211 2.5Gbe Test Drivers
endef

define Build/Prepare
	mkdir -p $(PKG_BUILD_DIR)
	$(CP) ./src/* $(PKG_BUILD_DIR)/
endef

##define Build/Configure
##	cd $(PKG_BUILD_DIR); \
##		$(BASH) ./kcompat-generator.sh
##endef

EXTRA_KCONFIG:= \
	CONFIG_IGB2=m

EXTRA_CFLAGS:= \
	$(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \
	$(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG)))) \
	-I$(PKG_BUILD_DIR)/include

define Build/Compile
	 $(KERNEL_MAKE) \
		M="$(PKG_BUILD_DIR)" \
		EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
		$(EXTRA_KCONFIG) \
		modules
endef

$(eval $(call KernelPackage,intel_211))
